package org.leumasjaffe.initiativeTracker.event;

import static org.leumasjaffe.initiativeTracker.operator.InitiativeController.tracker;

import java.awt.event.ActionEvent;

import javax.swing.Action;

import org.leumasjaffe.initiativeTracker.Constants;

import edu.wpi.heineman.xml.Message;
import edu.wpi.heineman.client.ServerAccess;

@SuppressWarnings("serial")
public class ChangeTurnAction extends InitiativeTrackerAction implements Action {

	public ChangeTurnAction (String text) {
		super(text);
	}
	
	@SuppressWarnings("null")
	@Override
	public void actionPerformed(ActionEvent e) {
		root.nextTurn();
		
		String xmlString = Message.requestHeader() + "<turnRequest game='" + Constants.id + " dot='";
		xmlString += tracker(Constants.id).list.get(tracker(Constants.id).root.getSubTurn()).getCharacter()
				.getDot() + "'/></request>";
		ServerAccess.getInstance().sendRequest(new Message(xmlString));
	}
	
}
